/**
 * 配置参考: https://cli.vuejs.org/zh/config/
 */
const webpack = require('webpack')
//本地json
const express = require('express')
const app = express()
var flare = require('./flare')
var apiRoutes = express.Router();
app.use('/api', apiRoutes)

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'windows.jQuery': 'jquery'
      })
    ]
  },
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  chainWebpack: config => {
    const svgRule = config.module.rule('svg')
    svgRule.uses.clear()
    svgRule
      .test(/\.svg$/)
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
  },
  // 默认打开eslint效验，如果需要关闭，设置成false即可
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    before(app) {
      app.get('/api/flare', (req, res) => {
        res.json({
          errno: 0,   // 这里是你的json内容
          data: flare
        })
      })
    },
    open: true,
    port: 8001,
    overlay: {
      errors: true,
      warnings: true
    }
  }
}
